<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="付款单号" prop="payOrderNo">
        <el-input
          v-model="queryParams.payOrderNo"
          placeholder="请输入付款单号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="业主姓名" prop="ownerName">
        <el-input
          v-model="queryParams.ownerName"
          placeholder="请输入业主姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="付款状态" prop="payState">
        <el-input
          v-model="queryParams.payState"
          placeholder="请输入付款状态"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="账单类型" prop="billType">
        <el-select v-model="queryParams.billType" placeholder="请选择账单类型" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>


      <el-form-item label="实际付款日期" prop="paidTime">
        <el-date-picker clearable size="small"
          v-model="queryParams.paidTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="付款日期">
        </el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-tabs type="border-card"  @tab-click="handleClick">
      <el-tab-pane label="收房付款单">
        <el-table v-loading="loading" :data="planList" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="合同编号" align="center" prop="contractNo" />
          <el-table-column label="小区(使用楼盘名)" align="center" prop="premiseName" />
          <el-table-column label="业主姓名" align="center" prop="ownerName" />

          <el-table-column label="付款状态" align="center" prop="payState" >
            <template slot-scope="scope">
              <span v-if="scope.row.payState==1">
                未付款
              </span>
              <span v-if="scope.row.payState==2">
                已付款
              </span>
              <span v-if="scope.row.payState==3">
                已终止
              </span>
              <span v-if="scope.row.payState==4">
                已冻结
              </span>
            </template>
          </el-table-column>
          <el-table-column label="账单类型" align="center" prop="billType" >
            <template slot-scope="scope">
              <span v-if="scope.row.billType==1">
                收房贷变更
              </span>
              <span v-if="scope.row.billType==2">
                 退租变更
              </span>
              <span v-if="scope.row.billType==3">
                普通账单
              </span>
              <span v-if="scope.row.billType==4">
              续约结算
              </span>
            </template>
          </el-table-column>
          <el-table-column label="支付金额" align="center" prop="paymentAmount" />

          <el-table-column label="预定付款日期" align="center" prop="payableDate" width="180">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.payableDate, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="实际付款日期" align="center" prop="paidTime" width="180">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.paidTime, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="第几期" align="center" prop="payNumber" />
          <el-table-column label="线下的支付方式" align="center" prop="payMethod" >

            <template slot-scope="scope">
              <span v-if="scope.row.payMethod==1">
               快捷同
              </span>
              <span v-if="scope.row.payMethod==2">
                支付宝
              </span>
              <span v-if="scope.row.payMethod==3">
                微信
              </span>
              <span v-if="scope.row.payMethod==4">
                现金
              </span>
              <span v-if="scope.row.payMethod==5">
                银行卡转账
              </span>
              <span v-if="scope.row.payMethod==6">
                POS刷卡
              </span>
              <span v-if="scope.row.payMethod==7">
                其他
              </span>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)"
                v-hasPermi="['system:plan:edit']" v-if="scope.row.payMethod==0 || scope.row.payMethod==''||scope.row.payMethod==null">支付</el-button>
              <span v-if="scope.row.payMethod!=0 && scope.row.payMethod!=''&& scope.row.payMethod!=null">--</span>
            </template>
          </el-table-column>
        </el-table>

      </el-tab-pane>
      <el-tab-pane label="租务付款单">
        <el-table v-loading="loading" :data="planList" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="合同编号" align="center" prop="contractNo" />
          <el-table-column label="小区(使用楼盘名)" align="center" prop="premiseName" />
          <el-table-column label="业主姓名" align="center" prop="ownerName" />

          <el-table-column label="付款状态" align="center" prop="payState" >
            <template slot-scope="scope">
              <span v-if="scope.row.payState==1">
                未付款
              </span>
              <span v-if="scope.row.payState==2">
                已付款
              </span>
              <span v-if="scope.row.payState==3">
                已终止
              </span>
              <span v-if="scope.row.payState==4">
                已冻结
              </span>
            </template>
          </el-table-column>
          <el-table-column label="账单类型" align="center" prop="billType" >
            <template slot-scope="scope">
              <span v-if="scope.row.billType==1">
                收房贷变更
              </span>
              <span v-if="scope.row.billType==2">
                 退租变更
              </span>
              <span v-if="scope.row.billType==3">
                普通账单
              </span>
              <span v-if="scope.row.billType==4">
              续约结算
              </span>
            </template>
          </el-table-column>
          <el-table-column label="支付金额" align="center" prop="paymentAmount" />

          <el-table-column label="预定付款日期" align="center" prop="payableDate" width="180">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.payableDate, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="实际付款日期" align="center" prop="paidTime" width="180">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.paidTime, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="第几期" align="center" prop="payNumber" />
          <el-table-column label="线下的支付方式" align="center" prop="payMethod" >

            <template slot-scope="scope">
              <span v-if="scope.row.payMethod==1">
               快捷同
              </span>
              <span v-if="scope.row.payMethod==2">
                支付宝
              </span>
              <span v-if="scope.row.payMethod==3">
                微信
              </span>
              <span v-if="scope.row.payMethod==4">
                现金
              </span>
              <span v-if="scope.row.payMethod==5">
                银行卡转账
              </span>
              <span v-if="scope.row.payMethod==6">
                POS刷卡
              </span>
              <span v-if="scope.row.payMethod==7">
                其他
              </span>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)"
                v-hasPermi="['system:plan:edit']" v-if="scope.row.payMethod==0 || scope.row.payMethod==''||scope.row.payMethod==null">支付</el-button>
              <span v-if="scope.row.payMethod!=0 && scope.row.payMethod!=''&& scope.row.payMethod!=null">--</span>
            </template>
          </el-table-column>

        </el-table>

      </el-tab-pane>
      <el-tab-pane label="金融服务付款单">
        <el-table v-loading="loading" :data="planList" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="合同编号" align="center" prop="contractNo" />
          <el-table-column label="小区(使用楼盘名)" align="center" prop="premiseName" />
          <el-table-column label="业主姓名" align="center" prop="ownerName" />

          <el-table-column label="付款状态" align="center" prop="payState" >
            <template slot-scope="scope">
              <span v-if="scope.row.payState==1">
                未付款
              </span>
              <span v-if="scope.row.payState==2">
                已付款
              </span>
              <span v-if="scope.row.payState==3">
                已终止
              </span>
              <span v-if="scope.row.payState==4">
                已冻结
              </span>
            </template>
          </el-table-column>
          <el-table-column label="账单类型" align="center" prop="billType" >
            <template slot-scope="scope">
              <span v-if="scope.row.billType==1">
                收房贷变更
              </span>
              <span v-if="scope.row.billType==2">
                 退租变更
              </span>
              <span v-if="scope.row.billType==3">
                普通账单
              </span>
              <span v-if="scope.row.billType==4">
              续约结算
              </span>
            </template>
          </el-table-column>
          <el-table-column label="支付金额" align="center" prop="paymentAmount" />

          <el-table-column label="预定付款日期" align="center" prop="payableDate" width="180">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.payableDate, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="实际付款日期" align="center" prop="paidTime" width="180">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.paidTime, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="第几期" align="center" prop="payNumber" />
          <el-table-column label="线下的支付方式" align="center" prop="payMethod" >

            <template slot-scope="scope">
              <span v-if="scope.row.payMethod==1">
               快捷同
              </span>
              <span v-if="scope.row.payMethod==2">
                支付宝
              </span>
              <span v-if="scope.row.payMethod==3">
                微信
              </span>
              <span v-if="scope.row.payMethod==4">
                现金
              </span>
              <span v-if="scope.row.payMethod==5">
                银行卡转账
              </span>
              <span v-if="scope.row.payMethod==6">
                POS刷卡
              </span>
              <span v-if="scope.row.payMethod==99">
                其他
              </span>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)"
                v-hasPermi="['system:plan:edit']" v-if="scope.row.payMethod==0 || scope.row.payMethod==''||scope.row.payMethod==null">支付</el-button>
              <span v-if="scope.row.payMethod!=0 && scope.row.payMethod!=''&& scope.row.payMethod!=null">--</span>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
    </el-tabs>


    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改【请填写功能名称】对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="付款单号" prop="payOrderNo">
          <el-input v-model="form.payOrderNo" placeholder="请输入付款单号" />
        </el-form-item>
        <el-form-item label="商户ID" prop="businessId">
          <el-input v-model="form.businessId" placeholder="请输入商户ID" />
        </el-form-item>
        <el-form-item label="合同ID" prop="contractId">
          <el-input v-model="form.contractId" placeholder="请输入合同ID" />
        </el-form-item>
        <el-form-item label="合同编号" prop="contractNo">
          <el-input v-model="form.contractNo" placeholder="请输入合同编号" />
        </el-form-item>
        <el-form-item label="合同类型" prop="contractType">
          <el-select v-model="form.contractType" placeholder="请选择合同类型">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="解约协议ID" prop="tTerminationId">
          <el-input v-model="form.tTerminationId" placeholder="请输入解约协议ID" />
        </el-form-item>
        <el-form-item label="楼盘ID" prop="premiseId">
          <el-input v-model="form.premiseId" placeholder="请输入楼盘ID" />
        </el-form-item>
        <el-form-item label="小区(使用楼盘名)" prop="premiseName">
          <el-input v-model="form.premiseName" placeholder="请输入小区(使用楼盘名)" />
        </el-form-item>
        <el-form-item label="业主ID" prop="ownerId">
          <el-input v-model="form.ownerId" placeholder="请输入业主ID" />
        </el-form-item>
        <el-form-item label="业主姓名" prop="ownerName">
          <el-input v-model="form.ownerName" placeholder="请输入业主姓名" />
        </el-form-item>
        <el-form-item label="租客ID(面向租客付款时才有)" prop="tenantId">
          <el-input v-model="form.tenantId" placeholder="请输入租客ID(面向租客付款时才有)" />
        </el-form-item>
        <el-form-item label="租客姓名" prop="tenantName">
          <el-input v-model="form.tenantName" placeholder="请输入租客姓名" />
        </el-form-item>
        <el-form-item label="付款类型
,1:收房付款单 2：租务付款单 3：解约结算付款 4：续约结算付款" prop="payType">
          <el-select v-model="form.payType" placeholder="请选择付款类型
,1:收房付款单 2：租务付款单 3：解约结算付款 4：续约结算付款">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="付款状态" prop="payState">
          <el-input v-model="form.payState" placeholder="请输入付款状态" />
        </el-form-item>
        <el-form-item label="账单类型" prop="billType">
          <el-select v-model="form.billType" placeholder="请选择账单类型">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="款项" prop="itemType">
          <el-select v-model="form.itemType" placeholder="请选择款项">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="其它款项
,款项为其它的时候，输入" prop="otherItemName">
          <el-input v-model="form.otherItemName" placeholder="请输入其它款项
,款项为其它的时候，输入" />
        </el-form-item>
        <el-form-item label="支付金额" prop="paymentAmount">
          <el-input v-model="form.paymentAmount" placeholder="请输入支付金额" />
        </el-form-item>
        <el-form-item label="实付金额" prop="realPaymentAmount">
          <el-input v-model="form.realPaymentAmount" placeholder="请输入实付金额" />
        </el-form-item>
        <el-form-item label="选择账期" prop="withPayPlanId">
          <el-input v-model="form.withPayPlanId" placeholder="请输入选择账期" />
        </el-form-item>
        <el-form-item label="账期开始日" prop="paymentDaysBegin">
          <el-date-picker clearable size="small"
            v-model="form.paymentDaysBegin"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择账期开始日">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="账期截止日" prop="paymentDaysEnd">
          <el-date-picker clearable size="small"
            v-model="form.paymentDaysEnd"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择账期截止日">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="预定付款日期" prop="payableDate">
          <el-date-picker clearable size="small"
            v-model="form.payableDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择预定付款日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="实际付款日期" prop="paidTime">
          <el-date-picker clearable size="small"
            v-model="form.paidTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择实际付款日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="第几期" prop="payNumber">
          <el-input v-model="form.payNumber" placeholder="请输入第几期" />
        </el-form-item>
        <el-form-item label="线下的支付方式" prop="payMethod">
          <el-input v-model="form.payMethod" placeholder="请输入线下的支付方式" />
        </el-form-item>
        <el-form-item label="其它支付方式
,支付方式为其它的时候，输入" prop="otherPayMethod">
          <el-input v-model="form.otherPayMethod" placeholder="请输入其它支付方式
,支付方式为其它的时候，输入" />
        </el-form-item>
        <el-form-item label="支付流水号" prop="payFlowNo">
          <el-input v-model="form.payFlowNo" placeholder="请输入支付流水号" />
        </el-form-item>
        <el-form-item label="租金(目前不含税，暂时和应付金额相同)" prop="rentalPrice">
          <el-input v-model="form.rentalPrice" placeholder="请输入租金(目前不含税，暂时和应付金额相同)" />
        </el-form-item>
        <el-form-item label="税费" prop="tax">
          <el-input v-model="form.tax" placeholder="请输入税费" />
        </el-form-item>
        <el-form-item label="操作人" prop="operationUser">
          <el-input v-model="form.operationUser" placeholder="请输入操作人" />
        </el-form-item>
        <el-form-item label="总期数" prop="totalPayNumber">
          <el-input v-model="form.totalPayNumber" placeholder="请输入总期数" />
        </el-form-item>
        <el-form-item label="还款类型(手续费,担保费,本息)" prop="repayType">
          <el-select v-model="form.repayType" placeholder="请选择还款类型(手续费,担保费,本息)">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
        <el-form-item label="预留字段1" prop="reserve1">
          <el-input v-model="form.reserve1" placeholder="请输入预留字段1" />
        </el-form-item>
        <el-form-item label="预留字段2" prop="reserve2">
          <el-input v-model="form.reserve2" placeholder="请输入预留字段2" />
        </el-form-item>
        <el-form-item label="预留字段3" prop="reserve3">
          <el-input v-model="form.reserve3" placeholder="请输入预留字段3" />
        </el-form-item>
        <el-form-item label="预留字段4" prop="reserve4">
          <el-input v-model="form.reserve4" placeholder="请输入预留字段4" />
        </el-form-item>
        <el-form-item label="预留字段5" prop="reserve5">
          <el-input v-model="form.reserve5" placeholder="请输入预留字段5" />
        </el-form-item>
        <el-form-item label="删除标识
,0:未删除，1：删除" prop="delFlg">
          <el-input v-model="form.delFlg" placeholder="请输入删除标识
,0:未删除，1：删除" />
        </el-form-item>
        <el-form-item label="创建用户ID" prop="createUserid">
          <el-input v-model="form.createUserid" placeholder="请输入创建用户ID" />
        </el-form-item>

        <el-form-item label="更新用户ID" prop="updateUserid">
          <el-input v-model="form.updateUserid" placeholder="请输入更新用户ID" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="30%"
      >
      <b><span>付款金额:{{this.sum}}</span></b><br>
      <template>
        <el-select v-model="value" placeholder="请选择支付方式">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </template>
      <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="submitForm">确 定</el-button>
  </span>
    </el-dialog>
  </div>
</template>

<script>
import { listPlan, getPlan, delPlan, addPlan, updatePlan } from "@/api/financial/plans";
import Link from "@/layout/components/Sidebar/Link";

export default {
  name: "Plan",
  components: {
    Link
  },
  data() {
    return {
      dialogVisible:false,
      options: [{
        value: '1',
        label: '快捷同'
      }, {
        value: '2',
        label: '支付宝'
      }, {
        value: '3',
        label: '微信'
      }, {
        value: '4',
        label: '现金'
      }, {
        value: '5',
        label: '银行转账'
      }, {
        value: '6',
        label: 'POS机刷卡'
      }, {
        value: '99',
        label: '其他'
      }],
      value: '',
      sum:'',
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      planList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        payOrderNo: null,
        businessId: null,
        contractId: null,
        contractNo: null,
        contractType: null,
        tTerminationId: null,
        premiseId: null,
        premiseName: null,
        ownerId: null,
        ownerName: null,
        tenantId: null,
        tenantName: null,
        payType: null,
        payState: null,
        billType: null,
        itemType: null,
        otherItemName: null,
        paymentAmount: null,
        realPaymentAmount: null,
        withPayPlanId: null,
        paymentDaysBegin: null,
        paymentDaysEnd: null,
        payableDate: null,
        paidTime: null,
        payNumber: null,
        payMethod: null,
        otherPayMethod: null,
        payFlowNo: null,
        rentalPrice: null,
        tax: null,
        operationUser: null,
        totalPayNumber: null,
        repayType: null,
        reserve1: null,
        reserve2: null,
        reserve3: null,
        reserve4: null,
        reserve5: null,
        delFlg: null,
        createUserid: null,
        updateUserid: null,
      },
      // 表单参数
      form: {},
      id:'',
      // 表单校验
      rules: {
        payOrderNo: [
          { required: true, message: "付款单号不能为空", trigger: "blur" }
        ],
        businessId: [
          { required: true, message: "商户ID不能为空", trigger: "blur" }
        ],
        contractId: [
          { required: true, message: "合同ID不能为空", trigger: "blur" }
        ],
        contractType: [
          { required: true, message: "合同类型", trigger: "change" }
        ],
        delFlg: [
          { required: true, message: "删除标识", trigger: "blur" }
        ],
        createUserid: [
          { required: true, message: "创建用户ID不能为空", trigger: "blur" }
        ],
        createTime: [
          { required: true, message: "创建时间不能为空", trigger: "blur" }
        ],
        updateUserid: [
          { required: true, message: "更新用户ID不能为空", trigger: "blur" }
        ],
        updateTime: [
          { required: true, message: "更新时间不能为空", trigger: "blur" }
        ]
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      listPlan(this.queryParams).then(response => {
        this.planList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
   reset2() {
    this.queryParams = {
      pageNum: 1,
      pageSize: 10,
      payOrderNo: null,
      businessId: null,
      contractId: null,
      contractNo: null,
      contractType: null,
      tTerminationId: null,
      premiseId: null,
      premiseName: null,
      ownerId: null,
      ownerName: null,
      tenantId: null,
      tenantName: null,
      payType: null,
      payState: null,
      billType: null,
      itemType: null,
      otherItemName: null,
      paymentAmount: null,
      realPaymentAmount: null,
      withPayPlanId: null,
      paymentDaysBegin: null,
      paymentDaysEnd: null,
      payableDate: null,
      paidTime: null,
      payNumber: null,
      payMethod: null,
      otherPayMethod: null,
      payFlowNo: null,
      rentalPrice: null,
      tax: null,
      operationUser: null,
      totalPayNumber: null,
      repayType: null,
      reserve1: null,
      reserve2: null,
      reserve3: null,
      reserve4: null,
      reserve5: null,
      delFlg: null,
      createUserid: null,
      updateUserid: null,
    };

  },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    handleClick(tab, event) {

      console.log(tab.index);
      if (tab.index==0) {
        this.queryParams.billType=null;
        this.queryParams.payType=1;
        this.getList();
      }
        if (tab.index==1){
          this.queryParams.billType=null;
        this.queryParams.payType=2;
          this.getList();
      }
        if (tab.index==2){
          this.queryParams.payType=null;
        this.queryParams.billType=1;
        this.getList();
      }
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加【请填写功能名称】";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.queryParams=row;
      this.sum=row.paymentAmount;
      this.id=row.id;
      console.log(this.id);
      this.dialogVisible=true;

    },
    /** 提交按钮 */
    submitForm() {

      this.queryParams.paidTime=new Date().toLocaleDateString();
      let date=this.queryParams.paidTime;
     let yea=date.substring(0,4);
     let moth=date.substring(5,6);
      let sun=date.substring(4,5);
      let day=date.substring(7,9);
      if (sun=='/'){
        date=yea+'-0'+moth+'-'+day;
      }else {
        date=yea+'-'+sun+moth+'-'+day;
      }
      this.queryParams.paidTime=date;

      console.log(date)
      this.queryParams.payMethod=this.value;
      console.log(this.queryParams.payMethod);
     if ( this.queryParams.payMethod==2) {

           this.reset2();
           window.location.href="http://m8yxqd.natappfree.cc/payOrder?id="+this.id;
           this.dialogVisible = false;

     }else{
       updatePlan(this.queryParams).then(response => {
         this.reset2();
         this.msgSuccess("修改成功");
         this.dialogVisible = false;
         this.getList();
       });
     }



    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除【请填写功能名称】编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delPlan(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('system/plan/export', {
        ...this.queryParams
      }, `system_plan.xlsx`)
    }
  }
};
</script>
